﻿<?php
defined('_JEXEC') or die('Restricted access'); 
 
jimport( 'joomla.html.html.tabs' );
JHtml::_('jquery.framework');
JHtml::_('behavior.keepalive');
JHTML::_('behavior.tooltip'); 
JHtml::_('behavior.framework');

?>
<script type="text/javascript">
	$(document).ready(function(){
		$("#o_code").change(function(){
			var outlet = $(this).find("option:selected").text();
			$('input[name="outlet"]').val(outlet);
		});
		$("#complain_type").change(function(){
			$('input[name="ctype"]').val($(this).find("option:selected").text());
		});
		$("#meal_period").change(function(){
			$('input[name="mperiod"]').val($(this).find("option:selected").text());
		});
	});
	//<![CDATA[
	Joomla.submitbutton = function(pressbutton){
		if (pressbutton == 'cancel') {
			submitform( pressbutton );
			return;
		}
		if (pressbutton == 'save') {
            var flag = true;
            
            if (document.adminForm.o_code.value == -1) {
                alert( 'Please select outlet!' );
                document.adminForm.o_code.focus();
                flag = false;
            }
            else if(document.adminForm.visit_date.value == "")
            {
                alert( 'Please choose visit date!' );
                document.adminForm.visit_date.focus();
                flag = false;
            }
            
            if(flag == true)
            {
                submitform( pressbutton );    
            }
			
		}
}
	
function isNumber(evt,val)
{
	if((val.length>11)&&(evt.which != 8)) return false;
	var charCode = (evt.which) ? evt.which : event.keyCode
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		{alert("Vui lòng nhấp số");return false;}
	return true;
  }
	
</script>

<form action="<?php echo JRoute::_("index.php?option=com_wrd")?>" method="post" name="adminForm" id="adminForm" >
		
    	<div class="row-fluid">
    
	   		<?php 
	   			echo JHtml::_('bootstrap.startTabSet', 'complain', array('active' => 'detail')); 
	   			echo JHtml::_('bootstrap.addTab', 'complain', 'detail', 'Details');
	   		?>
	    	
			<table class="table table-striped adminlist">
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Guest Name')?>:</label>
					</td>
					<td>
						<?php
							if(!empty($this->user_info->f_name) || !empty($this->user_info->l_name)){
								$guest_name = $this->user_info->l_name." ".$this->user_info->f_name ;
							}else{
								$guest_name = $this->data->guest_name ;
							}
						?>
						<input type="text" title="type" maxlength="25" size="25" value="<?php echo $guest_name ; ?>" id="guest_name" name="guest_name" class="guest_name"/> 
					</td>
					<td class="key">
						<label for="title"><?php echo JText::_('Outlet')?>:</label>
					</td>
					<td>
						<?php echo $this->lists['outlets']; ?>
					</td>
				</tr>
				<tr>
					<td class="key" valign="top">
						<label for="title"><?php echo JText::_('Member Id')?>:</label>
					</td>
					<td>
						<?php 
							if(!empty($this->user_info->member_id)){
								$vip_number = $this->user_info->member_id ;
							}else{
								$vip_number = $this->data->vip_number ;
							}
						?>
						<input type="text" title="type" maxlength="25" size="25" value="<?php echo $vip_number ; ?>" id="vip_number" name="vip_number" class="vip_number" />
					</td>
					<td class="key">
						<label for="title"><?php echo JText::_('Visit Date')?>:</label>
					</td>
					<td>
						<?php 
							echo JHTML::_ ( 'calendar', ($this->data->visit_date != '') ? $this->data->visit_date : '', 'visit_date', 'visit_date', '%Y-%m-%d');
						?> 
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Guest Type')?>:</label>
					</td>
					<td>
						<input type="text" title="type" maxlength="25" size="25" value="<?php echo $this->data->guess_type ; ?>" id="guess_type" name="guess_type" class="guess_type" />
					</td>
					<td class="key">
						<label for="title"><?php echo JText::_('Complain Type')?>:</label>
					</td>
					<td>
						<?php echo $this->lists['complain_type']; ?>
					</td>
				</tr>
				<tr>
					<td class="key">
						<label for="title"><?php echo JText::_('Meal Period')?>:</label>
					</td>
					<td>
						<?php echo $this->lists['meal_period']; ?> 
					</td>
					<td>Table Number</td>
					<td><input  type="text" name="table_no" id="table_no" value="<?php echo empty($this->data->table_no)? "": $this->data->table_no; ?>" size=30 /></td>
				</tr>
			</table>
			<table class="table table-striped adminlist">
	
				<tr>
					<td class="key" valign="top">
						<label for="title"><?php echo JText::_('Comment')?>:</label>
					</td>
					<td>
						<?php echo $this->lists['des'] ?>
					</td>
				</tr>
				<tr>
					<td class="key" valign='top'>
						<label for="title"><?php echo JText::_('Action Taken')?>:</label>
					</td>
					<td>
						<?php echo $this->lists['action_taken'] ;?>  
					</td>
				</tr>
				<tr>
					<td class="key" valign='top'>
						<label for="title"><?php echo JText::_('Follow Up')?>:</label>
					</td>
					<td>
						<?php echo $this->lists['follow_up']; ?> 
					</td>
				</tr>
				<tr>
					<td class="key" valign='top'>
						<label for="title"><?php echo JText::_('Management Input')?>:</label>
					</td>
					<td>
						<?php echo $this->lists['o_manager'] ;?> 
					</td>
				</tr>
            </table>
		

		<?php 
			echo JHtml::_('bootstrap.endTab');
			if(!empty($this->user_info)):
			echo JHtml::_('bootstrap.addTab', 'complain', 'infotab', 'User Infomation');
			?>
				<table>
					<tr>
						<td><?php echo JText::_('Member ID') ;?></td>
						<td>:</td>
						<td><strong>
							<?php
								if(!empty($this->user_info->member_id)){
									echo $this->user_info->member_id;
								}
							?> 
							</strong>
						</td>
						</tr>
					<?php if(!empty($this->user_info->prefix)): ?>	
					<tr>
						<td><?php echo JText::_('Name') ;?></td>
						<td>:</td>
						<td><strong>
							<?php
								if(!empty($this->user_info->f_name) || !empty($this->user_info->l_name)){
									$guest_name = $this->user_info->f_name." ".$this->user_info->l_name ;
								}else{
									$guest_name = $this->data->guest_name ;
								}
								echo $this->user_info->prefix.' '.$guest_name ; 
							?>
							</strong>	
						</td>
					</tr>
					<?php endif; ?>
					<tr>
							<td><?php echo JText::_('Mobile') ;?></td>
							<td>:</td>
							<td>
								<?php
									
									if(!empty($this->user_info->phone)){
										echo $this->user_info->phone;
									}
									else if(!empty($this->user_info->referer_phone)){
										echo $this->user_info->referer_phone;
									}
									else {
										echo "User have not mobiphone";
									}
								?>	
							</td>
						</tr>
					<tr>
						<td><?php echo JText::_('Date of Birth') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo $this->user_info->dob ; 
							?> 
						</td>
					</tr>
					<?php if(!empty($this->job)): ?>
					<tr>
						<td><?php echo JText::_('Job Title') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo empty($this->job) ? '' : $this->job ; 
							?> 
						</td>
					</tr>
					<?php endif; ?>
					<tr>
						<td><?php echo JText::_('Member Joining Date') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo $this->user_info->created_date ; 
							?> 
						</td>
					</tr>
					<?php  if(!empty($this->outlet->name)): ?>
					<tr>
						<td><?php echo JText::_('Outlet') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo empty($this->outlet->name) ? '' : $this->outlet->name ; 
							?> 
						</td>
					</tr>
					<?php endif;?>
					<tr>
						<td><?php echo JText::_('Current points balance') ;?></td>
						<td>:</td>
						<td>
							<?php
								//echo $this->p_o_u ; 
								echo number_format($this->p_o_u->point, 0,'.','.');
							?> 
						</td>
					</tr>
					<tr>
						<td><?php echo JText::_('Total Spending') ;?></td>
						<td>:</td>
						<td>
							<?php
								//echo $this->p_o_u ; 
								echo number_format($this->user_info->total_spend, 0,'.','.');
							?> 
						</td>
					</tr>
				</table>
			<?php 
			echo JHtml::_('bootstrap.endTab');
			if(!empty($this->l_tran)):
			echo JHtml::_('bootstrap.addTab', 'complain', 'ltran', 'Last transaction');
			?>
				<table>
					<tr>
						<td><?php echo JText::_('Outlet') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo $this->l_tran_outlet->name ;
							?> 
						</td>
					</tr>
					<?php if(!empty($this->l_tran->pax)): ?>
					<tr>
						<td><?php echo JText::_('Pax') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo $this->l_tran->pax ; 
							?> 
						</td>
					</tr>
					<?php endif; ?>
					<?php if(!empty($this->l_tran->food)): ?>
					<tr>
						<td><?php echo JText::_('Food') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo empty($this->l_tran->food) ? '' : $this->l_tran->food ; 
							?> 
						</td>
					</tr>
					<?php endif; ?>
					<?php if(!empty($this->l_tran->beverage)): ?>
					<tr>
						<td><?php echo JText::_('Beverage') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo empty($this->l_tran->beverage) ? '' : $this->l_tran->beverage ; 
							?> 
						</td>
					</tr>
					<?php endif;?>
					<?php if(!empty($this->l_tran->liquor)): ?>
					<tr>
						<td><?php echo JText::_('Liquor') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo empty($this->l_tran->liquor) ? '' : $this->l_tran->liquor ; 
							?> 
						</td>
					</tr>
					<?php endif; ?>
					<?php if($this->l_tran->other): ?>
					<tr>
						<td><?php echo JText::_('Other') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo empty($this->l_tran->other) ? '' : $this->l_tran->other ; 
							?> 
						</td>
					</tr>
					<?php endif; ?>
					<tr>
						<td><?php echo JText::_('Discount') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo $this->l_tran->discount ; 
							?> 
						</td>
					</tr>
					<tr>
						<td><?php echo JText::_('Net sale') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo $this->l_tran->netsale ; 
							?> 
						</td>
					</tr>
					<tr>
						<td><?php echo JText::_('Services charges') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo $this->l_tran->sc ; 
							?> 
						</td>
					</tr>
					<tr>
						<td><?php echo JText::_('Total') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo $this->l_tran->total ; 
							?> 
						</td>
					</tr>
					<tr>
						<td><?php echo JText::_('Date receipt') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo $this->l_tran->date_receipt ; 
							?> 
						</td>
					</tr>
					<?php if(!empty($this->l_tran->pay_type)): ?>
					<tr>
						<td><?php echo JText::_('Pay type') ;?></td>
						<td>:</td>
						<td>
							<?php
								echo $this->l_tran->pay_type ; 
							?> 
						</td>
					</tr>
					<?php endif; ?>
				</table>
			<?php echo JHtml::_('bootstrap.endTab');?>
	</div>
	<?php endif ;?>
	<?php endif ; ?>
	<input type="hidden" name="outlet" value="All" />
	<input type="hidden" name="ctype" value="Food" />
	<input type="hidden" name="mperiod" value="Breakfast" />
	<input type="hidden" name="handle_by" value="<?php echo $this->user->id;?>" />
	<input type="hidden" name="h_by" value="<?php echo $this->user->name;?>" />
	<input type="hidden" name="complain_flag" value="<?php echo $this->user_info->id ;?>" />
	<input type="hidden" name="phone" value="<?php echo $this->user_info->phone;?>" />
	<input type="hidden" name="dob" value="<?php echo $this->user_info->dob ;?>" />
	<input type="hidden" name="job" value="<?php echo $this->job;?>" />
	<input type="hidden" name="joining_date" value="<?php echo $this->user_info->created_date ;?>" />
	<input type="hidden" name="current_point" value="<?php echo $this->p_o_u->point;?>" />
	<input type="hidden" name="forward" value="<?php echo $this->forward ; ?>" />
	<input type="hidden" name="controller" value="complain" />
	<input type="hidden" name="option" value="com_wrd" />
	<input type="hidden" name="id" value="<?php echo (int)$this->data->id; ?>" />
	<input type="hidden" name="task" value="" />
	<?php 
	echo JHtml::_('bootstrap.endTabSet');
	echo JHTML::_( 'form.token' ); ?>
</form>
